package com.ruoyi.Amount.controller;

import com.ruoyi.Amount.domain.DTO.OrderSubmitDTO;
import com.ruoyi.Amount.domain.VO.OrderSubmitVO;
import com.ruoyi.Amount.result.Result;
import com.ruoyi.Amount.service.AmountReduce;
import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.order.domain.SysOrderOne;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/amount/reduce")
public class amountReduce {

    @Autowired
    private AmountReduce amountReduce;

    /**
     * 用户下单,单人批量，生成预支付效验单
     *
     * @param ordersSubmitDTO
     * @return
     */
    @Anonymous
    @PostMapping("/submit")
    @ApiOperation("用户下单")
    public Result<OrderSubmitVO> submit(@RequestBody OrderSubmitDTO ordersSubmitDTO) {
        OrderSubmitVO sysOrderOne = amountReduce.submitOrder(ordersSubmitDTO);
        return Result.success(sysOrderOne);
    }

    /**
     * 单人背调订单，下单支付
     *
     * @param order
     * @return
     */
    @PutMapping("/onepayment")
    @ApiOperation("订单支付")
    public Result onePayment(@RequestBody OrderSubmitVO order) throws Exception {
        return amountReduce.onePayment(order);
    }

    /**
     * 批量背调订单，下单支付
     *
     * @param order
     * @return
     */
    @PutMapping("/manypayment")
    @ApiOperation("订单支付")
    public Result manyPayment(@RequestBody OrderSubmitVO order) throws Exception {
        return amountReduce.manyPayment(order);
    }






}
